package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.FishClassifyDaoImpl;
import com.ysd.dao.impl.FishDetailsDaoImpl;
import com.ysd.entity.Details;
import com.ysd.entity.FishClassify;


public class ProductsServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//鱼的种类
		FishClassifyDaoImpl fishDao = new FishClassifyDaoImpl();
		List<FishClassify> fishClassifyList = fishDao.getFish();
		request.setAttribute("fishClassifyList", fishClassifyList);
		
		//利用id查鱼的详情
		//接受前台传来的信息
		int dId = Integer.parseInt(request.getParameter("fishClassifyId"));
		FishDetailsDaoImpl dDao = new FishDetailsDaoImpl();
		List<Details> detail = dDao.getDetailsList(dId);
		request.setAttribute("detail", detail);
		
		int fId = Integer.parseInt(request.getParameter("fishClassifyId"));
		FishDetailsDaoImpl fcDao = new FishDetailsDaoImpl();
		List<FishClassify> fcList = fcDao.getFCetails(fId);
		request.setAttribute("fcList", fcList);
		
		request.getRequestDispatcher("productlist.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
